<?php
/*
|
|--------------------------------------------------------------------------
| 首页数据
|--------------------------------------------------------------------------
|
*/
include 'includes/common.php';
include 'ss-config.php';
include 'includes/ss-db.php';
include 'includes/functions.php';
include 'includes/share.php';
include 'includes/leftdata_index.php';

//公司简介
$query = sprintf('SELECT PAGE_CONTENT FROM %spages WHERE ID = 1', DB_TBL_PREFIX);

mysql_query("set names 'utf8'");
$result = mysql_query($query, $GLOBALS['DB']) or die(mysql_error($GLOBALS['DB']));

if (mysql_num_rows($result))
{
	$row = mysql_fetch_assoc($result);
   $company_profile = str_intercept($row['PAGE_CONTENT'], 350) . '…';
}

mysql_free_result($result);


//新闻列表
$query = sprintf('SELECT ID, ART_TITLE, UNIX_TIMESTAMP(SUBMIT_DATE) AS SUBMIT_DATE FROM %sarticles WHERE IS_DELETE = 0 ORDER BY SUBMIT_DATE DESC LIMIT 0, 10', DB_TBL_PREFIX);

mysql_query("set names 'utf8'");
$result = mysql_query($query, $GLOBALS['DB']) or die(mysql_error($GLOBALS['DB']));

if (mysql_num_rows($result))
{
	$news = '<ul class="index_news">';
	
	$i = 0;
	
	while ($row = mysql_fetch_array($result))
	{
		//如果左侧列表达到限制数量就输出右侧列表
		if ($i == 5)
		{
			$news .= '</ul><ul class="index_news" style="margin-left:35px;">';
		}
		
		$news .= '<li><a href="xinwen-view-' . $row['ID'] . '.html">' . str_intercept($row['ART_TITLE'], 22) . '</a><span>' . date('Y-m-d', $row['SUBMIT_DATE']) . '</span></li>';
		
		$i = $i + 1;
	}
	
	 $news .= '</ul>';
}
else
{
	$news = '';
}

mysql_free_result($result);


//产品：复合井盖
$query = sprintf('SELECT ID, PRO_NAME, PRO_PRICE, PRO_IMAGE FROM %sproducts WHERE CAT_ID = 1 AND IS_SHOW = 0 AND IS_DELETE = 0 ORDER BY SUBMIT_DATE ASC LIMIT 0, 6', DB_TBL_PREFIX);

mysql_query("set names 'utf8'");
$result = mysql_query($query, $GLOBALS['DB']) or die(mysql_error($GLOBALS['DB']));

if (mysql_num_rows($result))
{
	$fhjg = '';
		   
	while ($row = mysql_fetch_array($result))
	{
		$fhjg .= '<li>';
	   $fhjg .= '<div class="p-img ld">';
	   $fhjg .= '<a href="fuhejinggai/chanpin-view-' . $row['ID'] . '.html"><img src="' . $row['PRO_IMAGE'] . '" width="145" height="117" alt="' . $row['PRO_NAME'] . '"></a>';
	   $fhjg .= '</div>';
	   //$fhjg .= '<div class="p-name"><a href="fuhejinggai/chanpin-view-' . $row['ID'] . '.html">' . $row['PRO_NAME'] . '</a></div>';
	   $fhjg .= '</li>';
	
	}
}
else
{
	$fhjg = '';
}

mysql_free_result($result);


//产品：树脂井盖
$query = sprintf('SELECT ID, PRO_NAME, PRO_PRICE, PRO_IMAGE FROM %sproducts WHERE CAT_ID = 2 AND IS_SHOW = 0 AND IS_DELETE = 0 ORDER BY SUBMIT_DATE ASC LIMIT 0, 6', DB_TBL_PREFIX);

mysql_query("set names 'utf8'");
$result = mysql_query($query, $GLOBALS['DB']) or die(mysql_error($GLOBALS['DB']));

if (mysql_num_rows($result))
{
	$szjg = '';
		   
	while ($row = mysql_fetch_array($result))
	{
		$szjg .= '<li>';
	   $szjg .= '<div class="p-img ld">';
	   $szjg .= '<a href="shuzhijinggai/chanpin-view-' . $row['ID'] . '.html"><img src="' . $row['PRO_IMAGE'] . '" width="145" height="117" alt="' . $row['PRO_NAME'] . '"></a>';
	   $szjg .= '</div>';
	   //$szjg .= '<div class="p-name"><a href="shuzhijinggai/chanpin-view-' . $row['ID'] . '.html">' . $row['PRO_NAME'] . '</a></div>';
	   $szjg .= '</li>';
	
	}
}
else
{
	$szjg = '';
}

mysql_free_result($result);


//产品：防盗井盖
$query = sprintf('SELECT ID, PRO_NAME, PRO_PRICE, PRO_IMAGE FROM %sproducts WHERE CAT_ID = 4 AND IS_SHOW = 0 AND IS_DELETE = 0 ORDER BY SUBMIT_DATE ASC LIMIT 0, 6', DB_TBL_PREFIX);

mysql_query("set names 'utf8'");
$result = mysql_query($query, $GLOBALS['DB']) or die(mysql_error($GLOBALS['DB']));

if (mysql_num_rows($result))
{
	$fdjg = '';
		   
	while ($row = mysql_fetch_array($result))
	{
		$fdjg .= '<li>';
	   $fdjg .= '<div class="p-img ld">';
	   $fdjg .= '<a href="fangdaojinggai/chanpin-view-' . $row['ID'] . '.html"><img src="' . $row['PRO_IMAGE'] . '" width="145" height="117" alt="' . $row['PRO_NAME'] . '"></a>';
	   $fdjg .= '</div>';
	   //$fdjg .= '<div class="p-name"><a href="fangdaojinggai/chanpin-view-' . $row['ID'] . '.html">' . $row['PRO_NAME'] . '</a></div>';
	   $fdjg .= '</li>';
	
	}
}
else
{
	$fdjg = '';
}

mysql_free_result($result);


//产品：铸铁井盖
$query = sprintf('SELECT ID, PRO_NAME, PRO_PRICE, PRO_IMAGE FROM %sproducts WHERE CAT_ID = 5 AND IS_SHOW = 0 AND IS_DELETE = 0 ORDER BY SUBMIT_DATE ASC LIMIT 0, 6', DB_TBL_PREFIX);

mysql_query("set names 'utf8'");
$result = mysql_query($query, $GLOBALS['DB']) or die(mysql_error($GLOBALS['DB']));

if (mysql_num_rows($result))
{
	$ztjg = '';
		   
	while ($row = mysql_fetch_array($result))
	{
		$ztjg .= '<li>';
	   $ztjg .= '<div class="p-img ld">';
	   $ztjg .= '<a href="zhutiejinggai/chanpin-view-' . $row['ID'] . '.html"><img src="' . $row['PRO_IMAGE'] . '" width="145" height="117" alt="' . $row['PRO_NAME'] . '"></a>';
	   $ztjg .= '</div>';
	   //$ztjg .= '<div class="p-name"><a href="guisujinggai/chanpin-view-' . $row['ID'] . '.html">' . $row['PRO_NAME'] . '</a></div>';
	   $ztjg .= '</li>';
	
	}
}
else
{
	$ztjg = '';
}

mysql_free_result($result);


//推荐产品(复合井盖和树脂井盖)
$query = sprintf('SELECT ID, PRO_NAME, PRO_PRICE, PRO_IMAGE FROM %sproducts WHERE CAT_ID = 7 AND IS_SHOW = 0 AND IS_DELETE = 0 ORDER BY SUBMIT_DATE ASC LIMIT 0, 7', DB_TBL_PREFIX);

mysql_query("set names 'utf8'");
$result = mysql_query($query, $GLOBALS['DB']) or die(mysql_error($GLOBALS['DB']));

if (mysql_num_rows($result))
{
	$tjcp = '';
		   
	while ($row = mysql_fetch_array($result))
	{
		$tjcp .= '<li>';
	   $tjcp .= '<div class="pic">';
	   $tjcp .= '<a href="fuhejinggai/chanpin-view-' . $row['ID'] . '.html"><img src="' . $row['PRO_IMAGE'] . '" width="145" height="117" alt="' . $row['PRO_NAME'] . '"></a>';
	   $tjcp .= '</div>';
	   $tjcp .= '<div class="title"><a href="fuhejinggai/chanpin-view-' . $row['ID'] . '.html">' . $row['PRO_NAME'] . '</a></div>';
	   $tjcp .= '</li>';
	
	}
}
else
{
	$tjcp = '';
}

mysql_free_result($result);


//调用首页模板
include 'templates/index.php';
?>